<template>
  <p ref="content" class="c-[#333] text-14 pr-10 flex flex-wrap break_all">{{copyContent}}</p>
  <span class="theme-color ml-2 text-13 ml-2 white-space" @click="onCopy">复制</span>
</template>
<script setup>
import { ref, defineProps } from 'vue'
import { showToast } from '@nutui/nutui';
import clipboard3 from 'vue-clipboard3'
defineProps({
  copyContent: {
    type: String
  }
})
// 解构方法
const { toClipboard } = clipboard3()
// 要复制的内容
let content = ref('')
const onCopy = async () => {
  try {
    await toClipboard(content.value)
    showToast.text('复制成功');
  } catch (err) {
    console.error(err)
    showToast.text('复制失败，请手动复制');
  }

}
</script>